package com.xh.demo.controller;

import com.xh.demo.commons.model.response.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ThreadLocalRandom;

/**
 * @author wen
 * @apiNote ProductStockController
 * @since 2021-12-10
 */
@Slf4j
@RestController
@RequestMapping("/product/stock")
public class ProductStockController {

    @GetMapping("/v1/{sku-id}")
    public R<Integer> detail(@PathVariable("sku-id") Long skuId) {
        return R.success(100);
    }

    @GetMapping("/v1/detail/{sku-id}")
    public R<String> detailV2(@PathVariable("sku-id") Long id) {
        String detail = String.format("product-sku-%s-detail", id);
        return R.success(detail);
    }

    @PutMapping("/v1/{sku-id}")
    public R<String> reStock(@PathVariable("sku-id") Long id) {
        String result = String.format("product-sku-%s-reStock-success", id);
        return R.success(result);
    }

}
